home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
NEW_TECH
/
WINCMD.ZIP
/
WINCMD.DOC
< prev
next >
Wrap
Text File
|
1993-04-07
|
47KB
|
1,003 lines
WINCMD.EXE (VERSION 1.0) Copyright (c) 1993 Douglas Boling
-------------------------------------------------------------------------
First Published in PC Magazine April 27, 1993 (Utilities)
-------------------------------------------------------------------------
WINCMD:
WINCMD is a Windows-based command file interpreter that
lets you create simple Windows 3.1 specific programs to automate repetivive
tasks.
Remember the DOS batch files with which you once proudly automated
all your routine tasks? If you've joined the mad rush to Windows, you've
simply had to learn to do without this useful and convenient facility.
The DOS batch file language may have been limited, but Windows supported
nothing at all in its place--until now.
WINCMD.EXE, this issue's utility, is a Windows-based command file
interpreter that lets you create simple Windows programs that perform
the repetitive functions that were once the domain of DOS batch files.
WINCMD goes far beyond the simple DOS batch file language, however.
Its language includes looping and branching statements along with
user-defined subroutines and functions. Both numeric and string
variables are supported, as is a full suite of arithmetic and logical
operators.
You can use any ASCII editor, such as Notepad, to create WINCMD
programs. Typically, these programs will carry a .WCM extension, though
this is not required unless you want the program to be callable from
another WINCMD program. A single .WCM file can be up to 64K in size,
though its executable parts (those not made up of comment lines) are
limited to about 45K.
USING WINCMD
Before discussing how to use WINCMD, I must start with some
terminology. WINCMD.EXE is the Windows program I've written.
It interprets programs--which are ASCII files--that are written in the
WINCMD language. To keep the two kinds of programs separate, I'll use
the full name and extension, WINCMD.EXE, when referring to the utility
itself. I'll refer to the ASCII files that WINCMD.EXE interprets as
WINCMD programs.
To install WINCMD.EXE, just copy it, along with WINCMD.ICO (its
icon file) and any .WCM files you have (two are supplied with the
program), into a directory on your path. Select the FileNew menu item
in the Program Manager and choose Program Item. Enter the short title
you want to appear under the icon as the Description, and enter the
complete path and WINCMD.EXE on the command line.
To make it easy to run WINCMD programs, you should then also use
the File Manager to associate the .WCM file extension with WINCMD.EXE.
To do this, start the Windows File Manager and select the FileAssociate
menu item. When the dialog box appears enter WCM, the WINCMD default
extension, in the edit box. In the Combo Box that lists the programs,
enter the path to and filename of WINCMD.EXE. Click on the OK button
and you're set!
From now on, any time you click on a WINCMD file in the File Manager
or Program Manager, Windows will automatically start WINCMD.EXE and pass
it the name of your WINCMD program. When WINCMD.EXE is started with a
filename on the command line, it will immediately start executing that
file. When WINCMD.EXE has finished executing the WINCMD program, it
will gracefully terminate.
Since debugging is important even for WINCMD programs, WINCMD.EXE
provides help in this area. If WINCMD.EXE is started with an /L command
switch before the WINCMD program name, WINCMD.EXE will display a window
with your WINCMD program loaded into memory, ready to execute. Be sure
not to place the /L after the WINCMD program name, or it will be
considered an argument to the command file. When WINCMD.EXE starts,
it performs some preprocessing on your WINCMD program. If it finds any
lines it does not understand, you'll get appropriate print error messages
with line numbers to help you find the problem.
Error messages are displayed for such faults as lines being too long
or numbers too big. When an error message is printed, WINCMD.EXE changes
to display two windows. The listing window displays the WINCMD program
with the line highlighted that is to be executed next. The output window
displays the last 100 lines printed by the WINCMD program as well as the
error messages.
WINCMD.EXE allows you to run a WINCMD program from the window in two
different ways. The program can be run normally either by pressing the
Run button or by selecting the RunRun Program menu selection. The
WINCMD.EXE window will then change to display only the output window and
run the WINCMD program. The Run button text will change to Stop.
Pressing the Stop button will cause WINCMD.EXE to stop executing
the WINCMD program and to display both the output and listing windows.
Again, the line in the program that would have been executed next is
highlighted. The program can then be restarted from this point simply
by clicking on the Run button. If you want to start the program from
the beginning, first click on the Reset button to reset the program and
then hit the Run button to start the program on its way. Note that when
WINCMD resets a program, it rereads the program from the disk. This
means that you can make changes to the program and then you can have
WINCMD load those changes by pressing the Reset button.
The other way to run a WINCMD program is by stepping through it
one line at a time. Single stepping is very handy to see exactly how
a WINCMD program is being executed. Each press of the Step button will
cause WINCMD.EXE to execute one line of the WINCMD program. The listing
window will highlight the next line to be executed.
WINCMD VARIABLES AND ARITHMETIC
The WINCMD syntax combines the power of a high-level language with
the simple command line operation of a batch language. Before discussing
the different WINCMD statements in detail, I should explain how WINCMD
programs use variables. The WINCMD language makes no distinction between
string variables and numeric variables. That is, a variable that has
been assigned a string value can later be assigned a number and vice versa.
Variables do not have to be declared before they are used. As you would
expect, variables are assigned using the equal sign.
The following three statements are examples of valid WINCMD
assignments.
var = 1
var = magazine
var = "I like PC Magazine"
In the first assignment above, the variable VAR is given the
value 1. The second assignment has the variable assigned the string
``magazine.'' In the third assignment, VAR is assigned the string ``I
like PC Magazine.'' The quotes allow spaces to be included in the string
assigned to VAR. If the quotes were not used, WINCMD would attempt to
assign the variable VAR with the string ``I'', but would then find the
additional characters on the line. WINCMD would then stop execution and
print the error message ``Extra characters on line.''
Variable names may contain numbers, letters, or the characters
_, $, %, and #, but the first character in a variable must always be
either a letter or underscore (_). Variable names are not case-sensitive;
the names BOB, Bob, and bob all refer to the same variable. Variable names
can be up to 253 characters long. Variables can be used anywhere strings
or numbers can be used in the program.
The numbers you use may range from -2,147,483,648 to 2,147,483,647,
and can be expressed in binary, octal, decimal, or hexadecimal format.
(In entering numbers, do not type in the commas shown above, however.)
The WINCMD default is base 10. To enter a nondecimal number, start the
number with a zero, then use b, o, or x as the second character,
indicating a binary, octal, or hexadecimal number, respectively. The
following four lines demonstrate different ways to write the decimal
value 100.
var = 100
var = 0x64
var =